import { Component, HostListener } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { StorageService } from '../shared/services/storage.service';
import { Profile } from './login/models/profile.model';

/**
 * Framework main component
 *
 * Author: Sorin Spiru
 * Date: 13.01.2018
 */
@Component({
    moduleId: module.id,
    templateUrl: 'framework.component.html',
    styleUrls: ['framework.component.scss']
})
export class FrameworkComponent {
    public routes: any[];
    public user: Profile;

    constructor(
        private route: ActivatedRoute) {
        this.user = StorageService.get().userInfo;
        this.routes = [
            {
                title: 'Home',
                path: 'home',
                imageCss: 'home',
                menuLevel: 0
            },
            {
                title:'Research',
                path:'research',
                imageCss: 'research',
                menuLevel: 0
            }
        ];
    }

    @HostListener("window:beforeunload", ["$event"]) unloadHandler(event: Event) {        
        StorageService.markExpired();
    }
}